﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using Models;

namespace DAL
{
    /// <summary>
    /// 操作日志DAL
    /// </summary>
   public class LogDAL
    {
        //操作日志添加
        public static int LogAdd(Log l)
        {
            string sql = "insert into tb_Log values(@OperTime,@Type,@OperPerson,@State,@ComputerName,@System,@UserID)";
            SqlParameter[] para = {
            new SqlParameter("@OperTime",l.OperTime),
            new SqlParameter("@Type",l.Type),
            new SqlParameter("@OperPerson",l.OperPerson),
            new SqlParameter("@State",l.State),
            new SqlParameter("@ComputerName",l.ComputerName),
            new SqlParameter("@System",l.System),
            new SqlParameter("@UserID",l.UserID),
            };
            return SqlDBHelper.ExecuteNonQuery(sql, para);
        }
        //操作日志查看
        public static DataTable LogSelect(int id)
        {
            string sql = "select * from tb_Log where UserID=" + id;
           
            return SqlDBHelper.GetDataTable(sql);
        }
        //操作日志删除
        public static int logDelete(int id)
        {
            string sql = "delete from tb_Log where LogID=" + id;
            return SqlDBHelper.ExecuteNonQuery(sql);

        }
    }
}
